using UnityEngine;
using System.Collections;

public class CustomData : MonoBehaviour 
{
    System.Object data;

    static public System.Object Get(GameObject go)
    {
        if (go == null)
            return null;

        CustomData customdata = go.GetComponent<CustomData>();

        if (customdata == null) 
            customdata = go.AddComponent<CustomData>();

        return customdata.data;
    }

    static public System.Object Get(Component comp)
    {
        if (comp == null)
            return null;

        return Get(comp.gameObject);
    }


    static public void Set(GameObject go, System.Object data)
    {
        if (go == null)
            return;

        CustomData customdata = go.GetComponent<CustomData>();

        if (customdata == null)
            customdata = go.AddComponent<CustomData>();

        customdata.data = data;
    }

    static public void Set(Component comp, System.Object data)
    {
        if (comp == null)
            return;

        Set(comp.gameObject, data);
    }
}
